package com.ferry.transport.netty.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * Created by daiyong
 */
public class JdkProxy extends AbstractProxy {
	@Override
	public <T> T newProxy(Class<T> interfaceClass, Object handler) {

		if (handler instanceof InvocationHandler) {
			Object proxyInstance = Proxy.newProxyInstance(handler.getClass().getClassLoader(), new Class<?>[]{interfaceClass}, (InvocationHandler) handler);
			return interfaceClass.cast(proxyInstance);
		}

		return null;
	}
}
